var dgram = require('dgram');
var server = dgram.createSocket("udp4");
//var ServerIP = "10.16.4.135"; // Trocar pelo IP do servidor na rede.
var ServerIP = "192.168.0.19"; // Trocar pelo IP do servidor na rede.


server.on("error", function(err) {
    console.log("server error:\n" + err.stack);
    server.close();
});

server.on("message", function(msg, rinfo) {
    console.log("server got: " + msg + " from " +
            rinfo.address + ":" + rinfo.port);
    var message = new Buffer("oi!");
    server.send(message, 0, message.length, 8088, "230.185.192.108");
});

server.on("listening", function() {
    var address = server.address();
    console.log("server listening " + address.address + ":" + address.port);
});

server.bind(8088, ServerIP, function() {
    server.setBroadcast(true);
    server.setMulticastTTL(128);
    server.addMembership('230.185.192.108', ServerIP);
});


console.log("multicasting");